import java.util.Currency;

public class MoneyConverter
{
	public double getRate(Currency from, Currency to)
	{
		double d = 1;
		return d;
	}

	public void setRate(Currency from, Currency to, double rate)
	{
	}

	public MoneyInterface convertTo(MoneyInterface money, Currency to)
	{
		if(money instanceof SimpleMoney)
		{
			SimpleMoney sm = (SimpleMoney)money;
			long na = sm.getAmount() * (long)getRate(sm.getCurrency(), to);
			return new SimpleMoney(na, to);
		}
		else
		{
			MixedMoney mm = (MixedMoney)money;
			long ta = 0;
			for(Currency currency: mm.getCurrencies())
			{
				long ca = mm.getAmount(currency);
				ta += (long)( getRate(currency, to) * ca);
			}
			return new SimpleMoney(ta, to);
		}
	}
}
